Skip to content

Add __all__ exports and improve backoff retry configuration#1993

Draft
iMicknl wants to merge 2 commits intov2/mainfrom
v2/developer-experience
Draft

Add __all__ exports and improve backoff retry configuration#1993
iMicknl wants to merge 2 commits intov2/mainfrom
v2/developer-experience

Conversation

@iMicknl
Copy link
Copy Markdown
Owner

@iMicknl iMicknl commented Apr 17, 2026

Summary

  • Add __all__ and re-exports to package __init__.py for cleaner public API
  • Add max_time and jitter to all backoff retry decorators for more resilient retry behavior

Test plan

  • Existing tests pass
  • Public API exports are importable from pyoverkiz
  • Retry behavior works with new max_time/jitter settings

iMicknl added 2 commits April 17, 2026 13:01
Define an explicit public API surface by re-exporting the most commonly
used classes (client, models, auth credentials, exceptions) from the
top-level pyoverkiz package.
Cap total retry duration with max_time on each decorator and add
full_jitter to avoid thundering herd on concurrent retries.
@iMicknl iMicknl requested a review from tetienne as a code owner April 17, 2026 13:03
Copilot AI review requested due to automatic review settings April 17, 2026 13:03
@iMicknl iMicknl added v2 enhancement New feature or request labels Apr 17, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to simplify the library’s public API by re-exporting commonly used symbols from pyoverkiz/__init__.py, and to make retry behavior more resilient by capping total retry duration and adding jitter to backoff decorators.

Changes:

  • Add max_time and jitter=backoff.full_jitter to all reusable backoff.on_exception decorators in pyoverkiz/client.py.
  • Add package-root re-exports and an explicit __all__ in pyoverkiz/__init__.py.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
pyoverkiz/client.py Adds max_time and jitter to backoff decorators to cap retry duration and reduce thundering-herd retries.
pyoverkiz/__init__.py Introduces top-level re-exports and __all__ to define a cleaner public import surface.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pyoverkiz/__init__.py
Comment on lines +7 to +13
from pyoverkiz.auth import (
Credentials,
LocalTokenCredentials,
RexelOAuthCodeCredentials,
TokenCredentials,
UsernamePasswordCredentials,
)
Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Importing credential classes from pyoverkiz.auth pulls in pyoverkiz.auth.factory and pyoverkiz.auth.strategies (via pyoverkiz/auth/__init__.py), which imports heavy optional runtime deps like boto3 at module import time. That makes a plain import pyoverkiz significantly heavier than necessary for users who only need models/exceptions. Prefer importing these symbols directly from pyoverkiz.auth.credentials (or use a lazy re-export via __getattr__) to keep top-level imports lightweight.

Copilot uses AI. Check for mistakes.
Comment thread pyoverkiz/__init__.py
Comment on lines +14 to +15
from pyoverkiz.client import OverkizClient
from pyoverkiz.exceptions import (
Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-exporting OverkizClient from the package root forces pyoverkiz/client.py to be imported on every import pyoverkiz. That module creates SSL_CONTEXT_LOCAL_API at import time, which loads the bundled CA cert from disk (blocking I/O). Consider making the client import lazy (PEP 562 __getattr__) and/or moving SSL context creation behind a lazy getter so importing the package doesn’t perform file I/O.

Copilot uses AI. Check for mistakes.
Comment thread pyoverkiz/__init__.py
Comment on lines +37 to +61
__all__ = [
"Action",
"ActionGroup",
"BadCredentialsException",
"BaseOverkizException",
"Command",
"Credentials",
"Device",
"Event",
"Execution",
"Gateway",
"LocalTokenCredentials",
"MaintenanceException",
"NotAuthenticatedException",
"OverkizClient",
"OverkizException",
"Place",
"RexelOAuthCodeCredentials",
"ServerConfig",
"Setup",
"State",
"TokenCredentials",
"TooManyRequestsException",
"UsernamePasswordCredentials",
]
Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New top-level re-exports/__all__ are part of the public API, but there’s no test asserting these names are importable from pyoverkiz (e.g., from pyoverkiz import OverkizClient, Credentials, Action). Adding a small importability test would prevent accidental breakage and ensure __all__ stays in sync with actual exports.

Copilot uses AI. Check for mistakes.
@iMicknl iMicknl marked this pull request as draft April 21, 2026 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request v2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants